package com.roc.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.roc.dao.DaoException;
import com.roc.dao.IRoleDao;
import com.roc.pojo.RoleBean;
@Repository
public class RoleDaoImpl extends BaseDaoImpl implements IRoleDao{

	@Override
	public List<RoleBean> queryRoleList(String orgCode) throws DaoException {
		// TODO Auto-generated method stub
		List<RoleBean> roleList=new ArrayList<RoleBean>();
		try {
			Session session = sessionFactory.getCurrentSession();
			String hql="from RoleBean r ,Operators o where o.roleType=r.roleCode and o.orgCode=:orgCode order by r.roleCode ASC ";
			Query query=session.createQuery(hql);
			query.setString("orgCode", orgCode);
			roleList=query.list();
		} catch (HibernateException e) {
			logger.debug(e.getMessage(), e);
			throw new DaoException("查询机构信息出错");
		}
		return roleList;
	}

}
